//
//  Macro.h
//  20240823
//
//  Created by 张伟 on 2024/8/24.
//

#ifndef Macro_h
#define Macro_h

#import <UIKit/UIKit.h>

// 屏幕宽度
#define KscreenWidth UIScreen.mainScreen.bounds.size.width

// 屏幕高度
#define KscreenHeight UIScreen.mainScreen.bounds.size.height

#define accountKey @"accountKey"
#define passwordKey @"passwordKey"
#define PROTECTION @"protection"


// 获取当前活动的窗口
#define WINDOW ({ \
    UIWindow *activeWindow = nil; \
    for (UIScene *scene in [UIApplication sharedApplication].connectedScenes) { \
        if (scene.activationState == UISceneActivationStateForegroundActive && [scene isKindOfClass:[UIWindowScene class]]) { \
            UIWindowScene *windowScene = (UIWindowScene *)scene; \
            for (UIWindow *window in windowScene.windows) { \
                if (window.isKeyWindow) { \
                    activeWindow = window; \
                    break; \
                } \
            } \
            if (activeWindow) { \
                break; \
            } \
        } \
    } \
    activeWindow; \
})

// 获取当前活动的窗口
#define GetActiveWindow ({ \
    UIWindow *activeWindow = nil; \
    for (UIWindowScene *windowScene in [UIApplication sharedApplication].connectedScenes) { \
        if (windowScene.activationState == UISceneActivationStateForegroundActive) { \
            activeWindow = windowScene.windows.firstObject; \
            break; \
        } \
    } \
    activeWindow; \
})

// 状态栏高度
#define kStatusBarHeight ({ \
    CGFloat statusBarHeight = 0; \
    UIWindow *activeWindow = GetActiveWindow; \
    if (activeWindow) { \
        statusBarHeight = activeWindow.windowScene.statusBarManager.statusBarFrame.size.height; \
    } \
    statusBarHeight; \
})

// 导航栏高度
#define kNavHeight (kStatusBarHeight + 44.0)

// tabBar 高度
#define kTabBarHeight (kStatusBarHeight > 20.0 ? 83.0 : 49.0)

// tabBar 底边高度
#define kTabBottomHeight (kStatusBarHeight > 20.0 ? 34.0 : 0)

//设置国际化语言
#define localizedStringKey(key) NSLocalizedString(key, key)

#endif /* Macro_h */
